package com.glory.good_dark.adapter;

import android.view.View;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.glory.good_dark.R;
import com.glory.good_dark.entity.MaterielFoolProofingEntity;

import java.util.List;

/**
 * FileName: MaterielFoolProofingListAdapter
 * Author: XJH
 * Date: 2020/5/18 14:51
 * Description:
 * History:
 */
public class MaterielFoolProofingListAdapter extends BaseQuickAdapter<MaterielFoolProofingEntity.MtmMatList, BaseViewHolder> {
    private OnOffEQPMatClickListener listener;

    public MaterielFoolProofingListAdapter(@Nullable List<MaterielFoolProofingEntity.MtmMatList> data) {
        super(R.layout.item_materiel_fool_proofing,data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MaterielFoolProofingEntity.MtmMatList item) {
        helper.setText(R.id.tvMaterielName,item.getMATERIAL_NAME());
        helper.setText(R.id.tvMaterielNum,item.getMAT_NO());
        helper.setText(R.id.tvMaterielType,item.getMATERIAL_TYPE());
        helper.setText(R.id.tvMaterielExpirationTime,item.getEXPIRATION_TIME());
        helper.setText(R.id.tvMaterielID,item.getMATERIAL_ID());
        helper.setText(R.id.tvMaterielOnTime,item.getONEQP_TIME());

        helper.getView(R.id.replaceMateriel_But).setOnClickListener(v -> {
            if (listener != null){
                listener.OnOffEQPMat(v,item);
            }
        });


    }

    public void setOnOffEQPMatClickListener(OnOffEQPMatClickListener listener){
        this.listener = listener;
    }


    public interface OnOffEQPMatClickListener{
        void OnOffEQPMat(View v, MaterielFoolProofingEntity.MtmMatList item);
    }
}
